#include <bits/stdc++.h>
using namespace std;

double d[100020], v[100020], a[100020], p[100020];
int  vis[100005];

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    for (int i = 1; i<= t; i++)
    {
        int n, m, L, ansa = 0;
        double V;
        cin >> n >> m >> L>>V;
        memset(vis, 0, sizeof(vis));
        for (int j = 1; j <= n; j++)
        {
            cin >> d[j] >> v[j] >> a[j];

        }
        for (int j = 1; j <= m; j++)
        {
            cin >> p[j];
        }
        for (int j = 1; j <= m; j++)
        {
            for (int k = 1; k <= n; k++)
            {
                double b = p[j] - d[k];
                if (v[k] * v[k]+ 2.0 * a[k] * b  < 0 || b < 0) continue;
                double spe = sqrt(v[k] * v[k]+ 2.0 * a[k] * b);
                if (spe > V)
                {

                    if (vis[k]==0)
                    {
                        vis[k] = 1;
                        ansa++;
                    }

                }
            }
        }
        if (a[1] >= 0)cout << ansa << ' ' << m - 1 << endl;

    }

    return 0;
}
